﻿#ifndef SETTINGS_H
#define SETTINGS_H

#include <QByteArray>
#include <QString>
#include <QSettings>
#include <QDebug>
#include <QFile>//csv使用到
#include <QDateTime>
#include <QStringList>
#include <QDir>
#include <QApplication>
#define EMB_MC_SW_ND         448     // 绣花机最大换色数                    原为288,lxs20220803客户有一个花样需要448色序,进行更改

#define CSV_ERROR "csverro.csv"
#define CSV_BREAK "breakag.csv"
#define CSV_DEBUGINFO "debuginfo.csv"
#define CSV_PROGRESS "progress.csv"
#define BREAKINFOFILE "breakInfo"

#define TYPE_ERROR 0
#define TYPE_BREAK  1
#define TYPE_DEBUGINFO  2

class Settings
{
public:
    Settings();

public:
    void loadSetting(QString configfile);
    inline QByteArray & getColorRgbArray() {return m_colorRGB;}
    void writeToIniFile(QString key, QVariant value);//写入值到ini文件
    QVariant readFromIniFile(QString key);//从ini文件读取值
    bool ifKeyExists(QString key);//判断是否存在键值

    void loadHMISetting(QString configfile);
    void writeToInHMIiFile(QString key, QVariant value);//写入值到HMIini文件
    QVariant readFromInHMIiFile(QString key);//从HMIini文件读取值
    bool ifHMIKeyExists(QString key);//判断是否存在键值

    void writeToCsv(QString strText,int type = 0);
    QStringList readToCsv(int type = 0);
    void clearToCsv(int type = 0);
    void fileClear(QString filePath);
private:
    QByteArray m_colorRGB;
    QString m_configFile;
    QString m_HMIconfigFile;

private:
    void fillDefaultColor();
    void HSItoRGB(float h,float s,float i,float *r,float *g,float *b);//hsb转换成rgb

};

#endif // SETTINGS_H
